package com.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EasyUITreeNode;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.content.service.ContentCategoryService;

/**
 * 内容管理controller
 * @author leaf
 *
 */
@Controller
public class ContentCategoryController {
	
	@Autowired
	private ContentCategoryService contentCategoryService;

	// 显示页面内容列表,逐级加载
	@RequestMapping("/content/category/list")
	@ResponseBody
	public List<EasyUITreeNode> getContentCategoryTreeNode(@RequestParam(value="id",defaultValue="0") Long parentId){
		List<EasyUITreeNode> result = contentCategoryService.getContentCategroyTreeNode(parentId);
		return result;
	}
	
	//添加节点
	@RequestMapping("/content/category/create")
	@ResponseBody
	public TaotaoResult createContentCategoryTreeNode(Long parentId,String name){
		TaotaoResult result = contentCategoryService.createNode(parentId, name);
		return result;
	}
	
	//添加节点
	@RequestMapping("/content/category/update")
	@ResponseBody
	public TaotaoResult updateContentCategoryTreeNode(Long id,String name){
		TaotaoResult result = contentCategoryService.updatateNode(id, name);
		return result;
	}
	
	//添加节点
		@RequestMapping("/content/category/delete")
		@ResponseBody
		public TaotaoResult deleteContentCategoryTreeNode(Long id){
			TaotaoResult result = contentCategoryService.deleteNode(id);
			return result;
		}
}
